﻿<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>流程发起列表</title>
  <link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
		<link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet">
		<link href="../Style/skin/css/style.css" rel="stylesheet" type="text/css" />
		<link href="../Style/skin/css/animate.css" rel="stylesheet" type="text/css" />
	<link href="Style/skin/font/iconfont.css" rel="stylesheet" type="text/css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
						<div class="ibox-content">
							<table  class="table  table-striped">
								<thead>
									<tr>
										<th width="40">#</th>
										<th>名称</th>
										
										<th colspan="2">查询</th>
										<th>发起</th>
									</tr>
								</thead>
								<tbody id="Table1"></tbody>
							</table>
							<div class="row">
								<div class="col-sm-12"><span id="Table2"></span></div>
							</div>
						</div>
				
			</div>

 <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../Scripts/config.js" type="text/javascript"></script>
    <script src="../Style/skin/layui/layer.js" type="text/javascript"></script>
   <script type="text/javascript">
		function GroupBarClick(groupName) {
				var alt = document.getElementById('Img' + groupName).alert;
				var sta = 'block';
				if(alt == 'Max') {
					sta = 'block';
					alt = 'Min';
					classname='fa fa-minus-square';
				} else {
					sta = 'none';
					alt = 'Max';
					classname='fa  fa-plus-square';
				}

				document.getElementById('Img' + groupName).className =classname;
				document.getElementById('Img' + groupName).alert = alt;

				var i = 0;
				for(i = 0; i <= 600; i++) {

					var row = document.getElementById(groupName + i);

					if(row == null || row == undefined || row.style == null)
						continue;

					if(sta == 'block') {
						row.style.display = '';
					} else {
						row.style.display = sta;
					}
				}
			}
		
       function WinOpenIt(url) {
           
           layer.open({
				  skin: 'layer-class',	
				  type: 2, 
				  title: '单流程查询', 
				  area:['96%','90%'],
				  content: url
				});
       }
    </script>
    <script language="javascript" type="text/javascript" >

        //发起时打开窗口
        function WinOpenStartFlow(flowNo) {

            var url = "MyFlow.htm?FK_Flow=" + flowNo;

            layer.open({
				  skin: 'layer-class',	
				  type: 2, 
				  title: flowNo, 
				  area:['96%','90%'],
				  content: url
				});
        }

        //查询
        function WinOpenSearch(flowNo,title) {

            var intFlowNo = flowNo;

            // var url = "./Rpt/Search.htm?RptNo=ND" + Number(flowNo) + "MyRpt&FK_Flow=" + flowNo;
            var url = "../RptDfine/Default.htm?RptNo=ND" + Number(flowNo) + "MyRpt&FK_Flow=" + flowNo;

            layer.open({
				  skin: 'layer-class',	
				  type: 2, 
				  title: title, 
				  area:['96%','90%'],
				  content: url
				});
        }

        //页面启动函数.
        $(function () {


            InitPage();
        });

        //初始化数据.
        function InitPage() {

            //初始化表格.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=Flowlist_Init&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }

                    data = JSON.parse(data);

                    var dtSort = data["Sort"]; //类别.
                    var dtFlow = data["Flows"]; //发起的流程.
					var listbox='';
                    var myNum = 0;
                    var is1 = false;
                    for (var i = 0; i < dtSort.length; i++) {

                        var sortNo = dtSort[i].No;
                        var sortName = dtSort[i].Name;

                        //检查该类别下是否有流程，没有流程就continue ;.
                        var isHaveFlow = false;
                        for (var idx = 0; idx < dtFlow.length; idx++) {

                            var flow = dtFlow[idx];
                            if (sortNo == flow.FK_FlowSort) {
                                isHaveFlow = true;
                                break;
                            }
                        }

                        if (isHaveFlow == false)
                            continue;

                        if (sortName == "" || sortName == null)
                            continue;

						listbox+="<tr  onclick=\"GroupBarClick('" + sortName + "')\" > <th colspan=8 class='table-title'> <i class='fa fa-minus-square' alert='Min'  id='Img" + sortName + "'></i><span>" + sortName + "</span></th> </tr>";
							
                        //增加处理.
                        for (var idx = 0; idx < dtFlow.length; idx++) {

                            var flow = dtFlow[idx];
                            var flowSort = flow.FK_FlowSort;
                            if (sortNo != flowSort)
                                continue;

                            myNum++;

                            if (is1 == true) {
                                listbox += "<tr  id='" + sortName + myNum + "' >";
                                is1 = false;
                            }
                            else {
                                listbox += "<tr  id='" + sortName + myNum + "' >";
                                is1 = true;
                            }

                            listbox += "<td class=Idx >" + myNum + "</td>";
                            listbox += "<td> <a href=\"javascript:WinOpenSearch('" + flow.No + "','" + flow.Name + "');\" > " + flow.No + "." + flow.Name + "</a></td>";
                            listbox += "<td> <a href=\"javascript:WinOpenStart('" + flow.No + "','" + flow.Name + "');\" >我发起的流程</a></td>";
                            listbox += "<td> <a href=\"javascript:WinOpenJoin('" + flow.No + "','" + flow.Name + "');\" >我审批的流程</a></td>";
                            listbox += "<td> <a href=\"javascript:WinOpenStartFlow('" + flow.No + "','" + flow.Name + "');\" >流程发起</a></td>";
                            listbox += "</tr>";

                        }
                    }
                    $('#Table1').html(listbox);
					$("#Table2").html("合计:" + myNum + "条");
                }
            });
        }

        //发起时打开窗口
        function WinOpenStartFlow(flowNo,title) {

            var url = "../MyFlow.htm?FK_Flow=" + flowNo;

            
            layer.open({
				  skin: 'layer-class',	
				  type: 2, 
				  title: title+' : 流程发起', 
				  area:['96%','90%'],
				  content: url
				});
        }

        //我发起的流程.
        function WinOpenStart(flowNo,title) {
            var intFlowNo = flowNo;
            var url = "../RptDfine/Default.htm?RptNo=ND" + Number(flowNo) + "MyRpt&FK_Flow=" + flowNo + "&SearchType=My";
           
            layer.open({
				  skin: 'layer-class',	
				  type: 2, 
				  title: title+' : 我发起的流程', 
				  area:['96%','90%'],
				  content: url
				});
        }

        //我发起的流程.
        function WinOpenJoin(flowNo,title) {
            var intFlowNo = flowNo;
            var url = "../RptDfine/Default.htm?RptNo=ND" + Number(flowNo) + "MyRpt&FK_Flow=" + flowNo + "&SearchType=MyJoin";
           
            layer.open({
				  skin: 'layer-class',	
				  type: 2, 
				  title:  title+' : 我审批的流程', 
				  area:['96%','90%'],
				  content: url
				});
        }

    </script>
</body>
</html>
